$(function query_sql() {
    $('#query_sql').click(function () {
        $('#add_info').html("");
        $.ajax({
            url: "/upgrade/query_romote/",
            data: {type:'sql'}, //data_form,
            type: "POST",
            dataType:'json',
            //获取后台的数据
            success: function (data) {
                // console.log(data);
                // $('#add_info').append(data.res)
                $('#add_info').append('Query successful!')
            }
        })
    })
})

$(function query_web() {
    $('#query_web').click(function () {
        $('#add_info').html("");
        $.ajax({
            url: "/upgrade/query_romote/",
            data: {type:'web'}, //data_form,
            type: "POST",
            //获取后台的数据
            dataType:'json',
            success: function (data) {
                // console.log(data);
                // $('#add_info').append(data.res)
                $('#add_info').append('Query successful!')
            }
        })
    })
})

$(function act_web() {
    $('#start_flask').click(function () {
        $('#add_info').html("");
        $.ajax({
            url: "/restart/",
            // data: {Upgrade_type: 0, Upgrade_oprate: 'Restart_Flask', oprater:0}, //data_form,
            type: "GET",
            //获取后台的数据
            dataType:'json',
            success: function (data) {
                console.log(data.res);
                alert(data.res);
            }
        })
    })
})

$(function query_runlog() {
    $('#query_locallog').click(function () {
        $('#add_info').html("");
        $.ajax({
            url: "/upgrade/get_runlog/",
            data: {type:'query_locallog'}, //data_form,
            type: "GET",
            //获取后台的数据
            dataType:'json',
            success: function (data) {
                // console.log(data);
                $('#add_info').append(data.res);
            }
        })
    })
})

$(function getLogInfo() {
    $("#logType").change(function getLogList(){
        var op_value = document.getElementById("logType").value;
        console.log("get logType,", op_value)
        $.ajax({
                url:  '/upgrade/getLogList/',
                data: {logType : op_value},
                type: "GET",
                dataType: "json",
                success: function (data) {
                    $("#add_info").empty();
                    $("#logName").empty();
                    $.each (data.install_files, function(i, item){
                        $("#logName").append("<option value=" + item + ">" + item + "</option>");  //添加一项option
                    })
                }
            });
    })
    });

$(function start_job() {
    $('#start_job').click(function () {
        $('#add_info').html("send post: /start_job - start_job");
        $.ajax({
            url: "/job/start_job/",
            data: {flag:'start', job_name: 'schedule_job'}, //data_form,
            type: "GET",
            //获取后台的数据
            dataType:'json',
            success: function (data) {
                console.log(data);
                console.log(data);
                alert(data.res);
            }
        })
    })
})

$(function end_job() {
    $('#end_job').click(function () {
        $('#add_info').html("send post: /start_job - end_job");
        $.ajax({
            url: "/job/start_job/",
            data: {flag:'end', job_name: 'schedule_job'}, //data_form,
            type: "GET",
            //获取后台的数据
            dataType:'json',
            success: function (data) {
                console.log(data);
                alert(data.res)
            }
        })
    })
})

$(function start_proxy() {
    $('#start_proxy').click(function () {
        $('#add_info').html("send post: /start_job - start_proxy ");
        $.ajax({
            url: "/job/start_job/",
            data: {flag:'start', job_name: 'flask_forward'}, //data_form,
            type: "GET",
            //获取后台的数据
            dataType:'json',
            success: function (data) {
                console.log(data);
                alert(data.res);
                //$('#add_info').append(data)
            }
        })
    })
})

$(function end_proxy() {
    $('#end_proxy').click(function () {
        $('#add_info').html("send post: /start_job - end_proxy ");
        $.ajax({
            url: "/job/start_job/",
            data: {flag:'end', job_name: 'flask_forward'}, //data_form,
            type: "GET",
            //获取后台的数据
            dataType:'json',
            success: function (data) {
                console.log(data);
                alert(data.res);
                //$('#add_info').append(data)
            }
        })
    })
})



